/*YuO8szH0cVixePu/Bt+mG2xEldcD/te7MH4FzhVNtb+Aw0Pn8HvMYyRA4OFSt14I*/
import { ajax, toast, cardCache } from 'nc-lightapp-front';
import { tableId, searchId, dataSource } from '../constants';
import { loginContext, getContext, loginContextKeys } from '../../../../public/components/arapInitInfo/loginContext';
let { setDefData, getDefData } = cardCache;

//点击查询，获取查询区数据
export default function clickSearchBtn(props, searchVal) {

    if (searchVal) {
        let transtype = getContext(loginContextKeys.transtype);
        let pageInfo = props.table.getTablePageInfo(this.tableId);
        let queryInfo = props.search.getQueryInfo(this.searchId);
        queryInfo.pageInfo = pageInfo;
        let data = {
            pageId: props.getSearchParam('p'),
            queryInfo: queryInfo,
            tradeType:transtype
        };
        setDefData(searchId, dataSource, data);//放入缓存
        ajax({
            url: '/nccloud/arap/gatheringbill/query.do',
            data: data,
            success: (res) => {
                let { success, data } = res;
                if (success) {
                    if (data) {
                        toast({ color: 'success', content: this.state.json['gatheringbill-000013']+data[this.tableId].allpks.length+this.state.json['gatheringbill-000014'] });/* 国际化处理： 查询成功，共,条*/
                        this.props.table.setAllTableData(this.tableId, data[this.tableId]);
                    } else {
                        toast({ color: 'warning', content: this.state.json['gatheringbill-000015'] });/* 国际化处理： 未查询出符合条件的数据*/
                        this.props.table.setAllTableData(this.tableId, { rows: [] });
                    }
                    setDefData(this.tableId, dataSource, data);//放入缓存
                    this.onSelected()
                }
            }
        });
    }

};

/*YuO8szH0cVixePu/Bt+mG2xEldcD/te7MH4FzhVNtb+Aw0Pn8HvMYyRA4OFSt14I*/